var member_id = store_id = '',
	ws;
document.addEventListener('plusready',function(){
	member_id = plus.storage.getItem('id');
	store_id = plus.storage.getItem('store_id');
	ws = plus.webview.currentWebview();
	//发布跳转
	$('.release').on('click',function(){
		var nwaiting = plus.nativeUI.showWaiting();//显示原生等待框
		var webviewContent= plus.webview.create('./Campus_release.html','Campus_release.html',{},{spage:ws.id});//后台创建webview并打开show.html
		webviewContent.addEventListener("loaded", function() { //注册新webview的载入完成事件
	        nwaiting.close(); //新webview的载入完毕后关闭等待框
	        webviewContent.show("slide-in-right",500); //把新webview窗体显示出来，显示动画效果为速度200毫秒的右侧移入动画
	    }, false);
	})
	
	pullfresh_fun(); 
},false);  
function pullfresh_fun(){ 
	plus.nativeUI.showWaiting('加载中...');
//	console.log(apiRoot+"?act=member_campus&op=campus"+member_id+'--'+store_id);
	$.ajax({  
		type:"post", 
		url:apiRoot+"?act=member_campus&op=campus",
		data:{member_id:member_id,store_id:store_id},
		dataType:'json',
		success:function(data){ 
			console.log(JSON.stringify(data));
			plus.nativeUI.closeWaiting();
			if(data.code == 200){
				var html = '';
				if(data.datas.length > 0){
					$.each(data.datas, function(k,v) { 
						html += '<ul class="mui-table-view campus_details" data-id="'+ v.xid +'">'+
									'<li class="mui-table-view-cell">'+
										'<a>'+
											'<img class="mui-media-object mui-pull-left" src="'+ user_pic + v.publisher.member_avatar +'">'+
											'<div class="mui-media-body">'+
												'<b>'+ (v.publisher.member_truename?v.publisher.member_truename:v.publisher.member_name) +'</b>'+ 
												'<h5>'+
													'<span>主题：'+ v.title +'</span>'+
													'<span><map class="mui-h5 red">￥</map>'+ v.remuneration +'</span>'+
												'</h5>'+
												'<p>服务时间：'+ v.targettime +'</p>'+
											'</div>'+
										'</a>'+
									'</li>'+
								'</ul>';
					});
					$('.Campus').html(html);
				}else{
					toast('没有该类型数据！'); 
				}
			}else{
				toast(data.datas.error);
			}
			//编辑   
			$('.campus_details').unbind('click');
			$('.campus_details').on('click',function(){
				var _this = $(this);
				var xid = _this.attr('data-id');
				var nwaiting = plus.nativeUI.showWaiting();//显示原生等待框
				var webviewContent= plus.webview.create('./Campus_details.html','Campus_details.html',{},{xid:xid,spage:ws.id});//后台创建webview并打开show.html
				webviewContent.addEventListener("loaded", function() { //注册新webview的载入完成事件
			        nwaiting.close(); //新webview的载入完毕后关闭等待框
			        webviewContent.show("slide-in-right",500); //把新webview窗体显示出来，显示动画效果为速度200毫秒的右侧移入动画
			    }, false);
			})
		}, 
		error:function(e){
			plus.nativeUI.closeWaiting();
			toast('连接失败！');
		}
	});
}